#include <iostream>
#include <random>
#include <time.h>
#include <windows.h>
using namespace std;
int ordinary(int* p,int n){
    int ans = 0;
    for(int i = 0;i < n;i++)
    ans += p[i];
    return ans;
}
void cur(int* p,int n){
    for(int m = n;m > 1;m = (m + 1) / 2){
        int i = 0;
    for(;i < m / 2;i++){
       p[i] = p[2 * i] + p[i * 2 + 1];}
       if(m % 2 == 1)
       p[i] = p[2 * i];
    }
    return;
}
int unroll(int* p,int n)
{
   int ans1 = 0;
   int ans2 = 0;
   if(n % 2 == 1)
   {
    ans1 += p[n - 1];
    for(int i = 0;i < n - 1;i += 2){
        ans1 += p[i];
        ans2 += p[i + 1];
    }
   } 
   else {
    for(int i = 0;i < n;i += 2){
        ans1 += p[i];
        ans2 += p[i + 1];
   }
   }
   return ans1 + ans2;
}
int main(){
    srand((unsigned)time(nullptr));
    int n;
    cin >> n;
    LARGE_INTEGER t1,t2,tc;
    QueryPerformanceFrequency(&tc);
    int* p =new int[n];
    for(int i = 0;i < n;i++){
        if(i % 2 == 0)
    p[i] = rand() % 100;
    else
    p[i] = -rand() % 100;
    }
    int ans1 = 0;
    int ans2 = 0;
    int ans3 = 0;
    double timeord = 0;
    double timeunroll = 0;
    double timecur = 0;
    QueryPerformanceCounter(&t1);
    ans1 = ordinary(p,n);
    QueryPerformanceCounter(&t2);
    timeord = (double)(t2.QuadPart-t1.QuadPart)/(double)tc.QuadPart; 
    QueryPerformanceCounter(&t1);
    ans2 = unroll(p,n);
    QueryPerformanceCounter(&t2);
    timeunroll = (double)(t2.QuadPart-t1.QuadPart)/(double)tc.QuadPart; 
    QueryPerformanceCounter(&t1);
    cur(p,n);
    ans3 = p[0];
    QueryPerformanceCounter(&t2); 
    timecur = (double)(t2.QuadPart-t1.QuadPart)/(double)tc.QuadPart; 
    cout << "timeord=" << timeord << endl;
    cout << "timeunroll=" << timeunroll << endl;
    cout << "timecur=" << timecur << endl;
    return 0;
}